require "vector"

light={}
local light=light
light.default={position=Vector{0,0,10}}
light.position=light.default.position
light.timeout=0
light.memory=light.default

function light.update(dt)

  light.timeout=light.timeout+dt
  if light.target then light.timeout=0 end
  if light.timeout>10 then light.target=light.default end
  light.memory=light.target or light.memory
  local route=light.memory.position+Vector{0,0,4}-light.position
  light.position=light.position+route*math.min(dt*(light.timeout>3 and 0.25 or 4),1) 
  
end

